﻿using Method_of_least_squares.Models;
namespace Method_of_least_squares
{
    internal class Program
    {
        /// <summary>
        /// 最小二乘法预测GDP
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //输入年份以及GDP数据
            List<double> year = new List<double>()
            {
                2011,2012,2013,2014,2015,2016,2017,2018,2019,2020
            };
            List<double> GDP = new List<double>()
             {   
                7551500124197,8532229986993,9570406235659,10475682920597, 11061553079871,
                11233276536744,12310409370894,13894817549380,1427993750060,14687673892882,
             };
            //输入年份
            Console.WriteLine("请输入要预测的年份");
            int Input = Convert.ToInt32( Console.ReadLine());
            //调用计算输出预测GDP
            Console.WriteLine($"预测{Input}年GDP值为：{LinearRegressionModel.LinearRegression( year, GDP,Input)}");
            //计算误差并输出
            double Deviation = (LinearRegressionModel.LinearRegression(year, GDP,Input) - 177340626455371) / 177340626455371;
            Console.WriteLine($"预测误差为：{ Deviation }" );


        }


    }
}